package com.ruoyi.web.controller.basicInformation;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.basicInformation.vo.TJudgeAlarmVo;
import com.ruoyi.system.basicInformation.bo.TJudgeAlarmQueryBo;
import com.ruoyi.system.basicInformation.bo.TJudgeAlarmAddBo;
import com.ruoyi.system.basicInformation.bo.TJudgeAlarmEditBo;
import com.ruoyi.system.basicInformation.service.ITJudgeAlarmService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 研判报警Controller
 * 
 * @author ruoyi
 * @date 2021-06-08
 */
@Api(value = "研判报警控制器", tags = {"研判报警管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/basicInformation/judgeAlarm")
public class TJudgeAlarmController extends BaseController {

    private final ITJudgeAlarmService iTJudgeAlarmService;

    /**
     * 查询研判报警列表
     */
    @ApiOperation("查询研判报警列表")
    @PreAuthorize("@ss.hasPermi('basicInformation:judgeAlarm:list')")
    @GetMapping("/list")
    public TableDataInfo<TJudgeAlarmVo> list(TJudgeAlarmQueryBo bo) {
        startPage();
        List<TJudgeAlarmVo> list = iTJudgeAlarmService.queryList(bo);
        return getDataTable(list);
    }
    /**
     * 查询研判报警列表
     */
    @ApiOperation("查询研判报警列表--map")
    @GetMapping("/listForMap")
    public TableDataInfo<TJudgeAlarmVo> listForMap(TJudgeAlarmQueryBo bo) {
        startPage();
        List<TJudgeAlarmVo> list = iTJudgeAlarmService.queryList(bo);
        return getDataTable(list);
    }
    /**
     * 导出研判报警列表
     */
    @ApiOperation("导出研判报警列表")
    @PreAuthorize("@ss.hasPermi('basicInformation:judgeAlarm:export')")
    @Log(title = "研判报警", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<TJudgeAlarmVo> export(TJudgeAlarmQueryBo bo) {
        List<TJudgeAlarmVo> list = iTJudgeAlarmService.queryList(bo);
        ExcelUtil<TJudgeAlarmVo> util = new ExcelUtil<TJudgeAlarmVo>(TJudgeAlarmVo.class);
        return util.exportExcel(list, "研判报警");
    }

    /**
     * 获取研判报警详细信息
     */
    @ApiOperation("获取研判报警详细信息")
    @PreAuthorize("@ss.hasPermi('basicInformation:judgeAlarm:query')")
    @GetMapping("/{id}")
    public AjaxResult<TJudgeAlarmVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iTJudgeAlarmService.queryById(id));
    }

    /**
     * 新增研判报警
     */
    @ApiOperation("新增研判报警")
    @PreAuthorize("@ss.hasPermi('basicInformation:judgeAlarm:add')")
    @Log(title = "研判报警", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody TJudgeAlarmAddBo bo) {
        return toAjax(iTJudgeAlarmService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改研判报警
     */
    @ApiOperation("修改研判报警")
    @PreAuthorize("@ss.hasPermi('basicInformation:judgeAlarm:edit')")
    @Log(title = "研判报警", businessType = BusinessType.UPDATE)
    @PutMapping()
    public AjaxResult<Void> edit(@RequestBody TJudgeAlarmEditBo bo) {
        return toAjax(iTJudgeAlarmService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除研判报警
     */
    @ApiOperation("删除研判报警")
    @PreAuthorize("@ss.hasPermi('basicInformation:judgeAlarm:remove')")
    @Log(title = "研判报警" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@PathVariable Long[] ids) {
        return toAjax(iTJudgeAlarmService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }
}
